1. Field of the Invention
Aspects of the present invention relate to an apparatus, a method, and a system for controlling communications between a host device and a USB device, and more particularly, to a USB device that can be used even during communications or charging via a USB without physically cutting a connection with a host device when no operations are performed in the host device, and a corresponding method.
2. Description of the Related Art
The Universal serial bus (USB) was created to standardize an interface for a connection between a computer and a computer peripheral, such as a mouse, a keyboard, a printer, a modem, or a speaker. Communication via USB accelerates installation and removal of complex adapters, such as drivers. For this reason, USB is now standard equipment in most PCs. USB has recently been used to transmit data and voices not only from computer peripherals, such as a modem or a printer, but also from home multimedia devices, such as telephones or audio players. USB is used even when data is transmitted from a cell phone or a digital camera to a host device.
FIG. 1 illustrates a USB device 110 connected to a host device 100 via a USB cable 120. The USB device 110 is connected to the host device 100 by linking the USB cable 120 to a USB connector 112 included in the USB device 110. The USB device 110 and the host device 100 transmit/receive data to/from each other through the linked USB cable 120. Computer peripherals and multimedia devices may be used as the USB device 110. A PC may be used as the host device 100.
FIG. 2 illustrates a structure for data transmission between a host device 200 and a USB device 210. The host device 200 includes a client software 202 and a plurality of memory buffers 204. Pipes 216 are connected to each of the buffers 204. The pipes 216 are connected to endpoints 214 in the USB device 210, such that the pipes 216 serve as tunnels for communications between the host device 200 and the USB device 210. The endpoints 214 are grouped to form an interface 212. The client software 202 in the host device 200 communicates with the USB device 210 via a communication set. As described above, the data transmission between the host device 200 and the USB device 210 is carried out via the endpoints 214. The data transmission is always carried out in a form where a host controller (not shown) processes the endpoints 214 of the USB device 210. The USB device 210 cannot transmit data without a request or permission.
FIG. 3 is a flowchart of a data process between a host device 300 and a USB device 330. FIG. 3 shows a data process between the host device 300, a USB controller 310, and a central processing unit (CPU) 320 and particularly, shows a bulk data transmission. The USB controller 310 and the CPU 320 are part of the USB device 330.
In operation 301, an application initiates a data transmission. In operation 302, the host device 300 prepares a data packet to be transmitted. In operation 303, when the data packet is prepared, the host device 300 transmits the prepared data packet to the USB controller 310 of the USB device 330. In operation 311, the USB controller 310 checks whether an endpoint is ready for the data packet received from the host device 300. If the endpoint is ready, operation 312 is performed. If the endpoint is not ready, operation 315 is performed.
In operation 312, the USB controller 310 receives data if the endpoint is in a ready status. In operation 313, the USB controller 310 sets the status of the endpoint to a busy status, and in operation 314, the USB controller 310 transmits an ACK packet to the host device 300. If the status of the endpoint is set to be a busy status in operation 313, the USB controller 310 informs the CPU 320 of the set status by interrupting the CPU 320 of the USB device 330 while operation 314 is being performed in operation 316. If the endpoint is not in a ready status, the USB controller 310 transmits a NACK packet to the host device 300 in operation 315.
Looking at the host device 300, the host device 300 checks the data packet received from the USB controller 310 in operation 304. If the received data packet is the ACK packet, operation 305 is carried out. If the received data packet is the NACK packet, the data is re-transmitted in operation 307. In operation 305, the host device 300 checks whether all of the data is transmitted. If all of the data has been transmitted, the data process is concluded. If not all of the data is transmitted, next data is transmitted in operation 306.
Looking at the CPU 320, in operation 321, the CPU 320 processes the data received from the host device 300 by, for example, reading and storing the received data in a memory. In operation 322, the CPU 320 sets the status of the endpoint to a ready status and allows the USB controller 310 to receive the next data. The CPU 320 processes the received data in operation 323, and returns the processed data to the USB controller 310 in operation 324.
As described above, while the USB device 330 is connected to the host device 300, the USB device 330 cannot recognize the time when the host device 300 will transmit data, because a communication process, that is, data transmission/reception, always starts from the host device 300. Accordingly, the USB device 330 cannot perform other unique operations of the USB device during USB communications. The operation of the USB device 330 is determined according to the type of data received from the host device 300, and the capacity of a process for communications between the USB device 330 and the host device 300 is large. Accordingly, when the USB device 330 performs any operation without knowing the status of the host device 300, the communications between the USB device 330 and the host device 300 may collide with the unique operation performed by the USB device 330. This may interrupt the communications of the USB device 330 with the host device 300.